using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using QxFramework.Core;

public class TaskBoard : MonoBehaviour
{

    private bool isPlayerIn;
    private ICameraManager _iCameraManager;
    private bool isUIOpen;
    void Start()
    {
    }

    void Update()
    {
        if (_iCameraManager == null)
            _iCameraManager = GameMgr.Get<ICameraManager>();
        if (isPlayerIn)
        {
            if (Input.GetKeyDown(KeyCode.F))
                if (!UIManager.Instance.OpenUICheck("TaskMenu"))
                {
                    isUIOpen = true;
                    UIManager.Instance.Open("TaskMenu", "", 5);
                    _iCameraManager.isLocked(!isUIOpen);
                }
                else
                {
                    isUIOpen = false;
                    UIManager.Instance.Close("TaskMenu");
                    _iCameraManager.isLocked(!isUIOpen);
                }
        }
        else if (isUIOpen)
        {
            isUIOpen = false;
            UIManager.Instance.Close("TaskMenu");
            _iCameraManager.isLocked(!isUIOpen);
        }
    }

    private void OnTriggerEnter2D(Collider2D collision)
    {
        if (collision.GetComponent<PlayerControl>() != null)
            isPlayerIn = true;
    }
    private void OnTriggerExit2D(Collider2D collision)
    {
        if (collision.GetComponent<PlayerControl>() != null)
            isPlayerIn = false;
    }
}
